FAQ - Pilot and general syntax
How do I do token replacement?
Any statement outside of the RUN PGM= and ENDRUN block (see RUN … ENDRUN) is a TPMain statement. We can use TPMain statements to set global variables, check results, run loops etc. Do the following substitution:
INHWYNET="c20c.net" OUTHWYNET="c20ctpp.net" RUN PGM=NETWORK FILEI NETI=@INHWYNET@ FILEO NETO=@OUTHWYNET@ ENDRUN RUN PGM=HWYLOAD FILEI NETI=@OUTHWYNET@ ..... ENDRUN
We can put all the substitution at the beginning of the file and change them there before running the script. Alternatively, we can put the substitution strings in a separate file and use the READ statement to insert it at run time:
READ FILE=sub.txt RUN PGM=HWYNET FILEI NETI=@INHWYNET@ .....
How do I generate unique link ID strings using numeric values from A and B nodes?
Voyager provides a set of Character functions to allow conversion and manipulation of character (or string or text) variables:
FORMAT(x,w,d,str) ; Format number (x) with width=w, decimals=d, format=str TRIM(str) ; Delete trailing spaces from str LTRIM(str) ; Delete leading spaces from str DUPSTR(str,n) ; Duplicate str n times; result must be less than 100 chars VAL(str) ; Return the numeric value contained in str ; Convert the variable v to a string that is w characters wide, ; with d decimal places. n must be less than 30; d less than n - 2. STR(v,w,d) ; Extract a substring from str, beginning at position b, ; and continuing for n characters. b must be greater than 0. SUBSTR(str,b,n) ; Return the position in str2 where str begins. If str does not exist in ; str2, the value is 0. Both strings are case sensitive. ; Note: str is either a character constant '...', or a character variable STRPOS(str,str2) ; The following statement will generate a unique link ID string for each ; link: LINK_ID= LTRIM(STR(LI.1.A, 5, 0)) + '_' + LTRIM(STR(LI.1.B, 5, 0))